package com.bcxj.apidriver.controller;

import com.bcxj.apidriver.service.VerificationCodeService;
import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.dto.VerificationCodeDTO;
import com.bcxj.internalcommon.response.TokenResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: VerificationCodeController
 * Package: com.bcxj.apidriver.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/10/20 17:55
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@Slf4j
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;


    /**
     * 司机登录发送验证码
     * @param verificationCodeDTO
     * @return
     */
    @GetMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        log.info("登录司机的手机号为:{}", verificationCodeDTO.getDriverPhone());
        return verificationCodeService.checkAndSendVerificationCode(verificationCodeDTO.getDriverPhone());
    }


    @PostMapping("/verification-code-check")
    public ResponseResult<TokenResponse> verificationCodeCheck(@RequestBody VerificationCodeDTO verificationCodeDTO) {
        return verificationCodeService.checkCode(verificationCodeDTO);
    }


}
